﻿using System.Web.Mvc;
using Castle.Windsor;
using Turquoise.Web.Management.Infrastructure.CastleInstallers;
using Turquoise.Web.Common.Infrastructure;
using Turquoise.Web.Management.Infrastructure.CastleInstallers;

namespace Turquoise.Web.Management.Infrastructure
{
    public static class IoCInstaller
    {
        public static void CastleInstaller()
        {
            var container = new WindsorContainer()
                .Install(new DatabaseContextInstaller())
                .Install(new RepositoryInstaller())
                .Install(new ServiceInstaller())
                .Install(new ControllerInstaller())
                .Install(new AspectInstaller())
                ;
            var controllerFactory = new CastleControllerFactory(container.Kernel);
            ControllerBuilder.Current.SetControllerFactory(controllerFactory);
        }
    }
}